import 'package:common_utils/common_utils.dart';
import 'package:dio/dio.dart';
import 'package:x_core/res/x_constant.dart';
import 'package:x_core/util/sp_utils.dart';

/// Created by XieXin on 2020/3/18.
/// 统一添加身份验证请求头
class AuthInterceptor extends Interceptor {
  @override
  void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
    String token = SPUtils.getString(XConstant.token);
    if (!TextUtil.isEmpty(token)) {
      options.headers['token'] = token;
    }
    return super.onRequest(options, handler);
  }
}
